package com.example.zhu29.bledemo.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.zhu29.bledemo.R;
import com.inuker.bluetooth.library.search.SearchResult;

import java.util.List;

/**
 * Created by Administrator on 2017/12/12.
 * Bluetooth List Adapter
 */

public class MyBLEListAdapter extends BaseQuickAdapter<SearchResult, BaseViewHolder> {
    public MyBLEListAdapter(@Nullable List<SearchResult> data) {
        super(R.layout.adapter_ble_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SearchResult item) {
        String address = item.getAddress();
        String name = item.getName();
        if (!TextUtils.isEmpty(name)) {
            helper.setText(R.id.tv_name, name);
        } else {
            helper.setText(R.id.tv_name, R.string.unknown_device);
        }
        if (!TextUtils.isEmpty(address)) helper.setText(R.id.tv_address, address);
    }
}
